<?php

namespace App\Repository;

use App\Base\IRI;
use App\Entity\AdminGroup;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;

/**
 * @method AdminGroup|null find($id, $lockMode = null, $lockVersion = null)
 * @method AdminGroup|null findOneBy(array $criteria, array $orderBy = null)
 * @method AdminGroup[]    findAll()
 * @method AdminGroup[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class AdminGroupRepository extends DocumentRepository
{
    public function __construct(DocumentManager $dm)
    {
        parent::__construct($dm, $dm->getUnitOfWork(),$dm->getClassMetadata(AdminGroup::class));
    }


    public function get4Choice()
    {
        $data = $this->findAll();
        $re = [];
        foreach ($data as $one) {
            $re[]=[
                "id"=>IRI::createIRIStringFromEntity(AdminGroup::class,$one->getId()),
                "value"=>$one->getName(),
            ];
        }
        return $re;
    }

}
